<?php

namespace App\Http\Controllers\Operation;

use App\Http\Controllers\Controller;
use App\Models\Operation\OperationFile;
use Illuminate\Http\Request;

class OperationController extends Controller
{
    /**
     * 保险列表
     *
     * @param  Request  $request
     *
     * @return mixed
     */
    public function operationFileList(Request $request)
    {
        return response()->formatJson(OperationFile::all()->toArray());
    }

    /**
     * 添加保险
     *
     * @param  Request  $request
     *
     * @return mixed
     */
    public function storeOperationFile(Request $request)
    {
        $params = $request->all();
        $params['type'] = 'operation';
        $file = new OperationFile($params);

        $result = $file->save();

        $message = $result ? '添加成功' : '添加失败';

        return response()->formatJson(['result' => $result], $message);
    }
}
